/********************************************************************
        created:        2010/02/23
        filename:       htl_poll.h
        author:         HongLiang

        purpose:    	poll
*********************************************************************/
#ifndef __HTL_POLL_H__
#define __HTL_POLL_H__
#include "../container/htl_config.h"
#include "../container/htl_vector.h"
#include <poll.h>
__HTL_BEGIN_NAMESPACE
class poll_aux : public ioevent {
public:
	poll_aux() :  maxfds(-1) {}
	virtual ~poll_aux() {}
	HTL_RESULT event_init(int _maxfds = 1024);
	HTL_RESULT event_add(int fd, int events);
	HTL_RESULT event_mod(int fd, int events);
	HTL_RESULT event_del(int fd);
	HTL_RESULT event_register(int fd, call_handler handler);
	HTL_RESULT event_unregister(int fd);
	HTL_RESULT event_poll(void* args, int timeout_ms);
protected:
    int maxfds;
	struct poll_event {
		pollfd poll_fd;
		int events;
		poll_event() : events(-1) { 
			poll_fd.fd = -1;
		}
		poll_event(int args) : events(args) {
			poll_fd.fd = -1;
		}
	};
	htl::vector<poll_event> poll_events;
	htl::vector<call_handler> sequence_handler;
};

__HTL_END_NAMESPACE
#endif
